aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/sujet/[slug].tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-06 17:55:24 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-06 18:14:42 +0100
commitb9c1953c79688fc3f536b7927692309c9780b5da (patch)
tree673a26c0b0a9cc587f89d1eea9af739c3f17daf2 /src/pages/sujet/[slug].tsx
parent544f8cd400f888464a18ee30836f63d4b93a0822 (diff)
refactor: reuse PostMeta components on single articles/pages
Diffstat (limited to 'src/pages/sujet/[slug].tsx')
-rw-r--r--src/pages/sujet/[slug].tsx34
1 files changed, 12 insertions, 22 deletions
diff --git a/src/pages/sujet/[slug].tsx b/src/pages/sujet/[slug].tsx
index 527d529..bcea544 100644
--- a/src/pages/sujet/[slug].tsx
+++ b/src/pages/sujet/[slug].tsx
@@ -5,13 +5,14 @@ import { NextPageWithLayout } from '@ts/types/app';
import { SubjectProps } from '@ts/types/taxonomies';
import { loadTranslation } from '@utils/helpers/i18n';
import { GetStaticPaths, GetStaticProps, GetStaticPropsContext } from 'next';
-import Image from 'next/image';
import { ParsedUrlQuery } from 'querystring';
import styles from '@styles/pages/Subject.module.scss';
import {
getAllSubjectsSlug,
getSubjectBySlug,
} from '@services/graphql/queries';
+import PostHeader from '@components/PostHeader/PostHeader';
+import { ArticleMeta } from '@ts/types/articles';
const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {
const getPostsList = () => {
@@ -22,29 +23,18 @@ const Subject: NextPageWithLayout<SubjectProps> = ({ subject }) => {
));
};
+ const meta: ArticleMeta = {
+ website: subject.officialWebsite,
+ };
+
return (
<article>
- <header>
- <h1 className={styles.title}>
- {subject.featuredImage && (
- <span className={styles.cover}>
- <Image
- src={subject.featuredImage.sourceUrl}
- alt={subject.featuredImage.altText}
- layout="fill"
- />
- </span>
- )}
- {subject.title}
- </h1>
- {subject.officialWebsite && (
- <dl>
- <dt>{t`Official website:`}</dt>
- <dd>{subject.officialWebsite}</dd>
- </dl>
- )}
- <div dangerouslySetInnerHTML={{ __html: subject.intro }}></div>
- </header>
+ <PostHeader
+ cover={subject.featuredImage}
+ intro={subject.intro}
+ meta={meta}
+ title={subject.title}
+ />
<div dangerouslySetInnerHTML={{ __html: subject.content }}></div>
{subject.posts.length > 0 && (
<div>